<%@ page language="java" contentType="text/html; charset=UTF-8" %>
<%@ include file="/WEB-INF/view/common/includes.jsp" %>
<%@ include file="/WEB-INF/view/inc.jsp" %>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title></title>
</head>
<style>
    .panel-body {
        border-bottom-width: 0px;
        border-left-width: 0px;
    }

    .layout-expand .panel-header {
        border-width: 0px;
    }

</style>
<body class="easyui-layout" data-options="fit:true,border:false">
<!-- 搜索框 -->
<div data-options="region:'north',title:'查询条件',border:false" style="height:80px; overflow: hidden;border: 0px;">
    <form id="searchForm">
        <div class="fitem fl">
            <label>菜谱名称:</label>
            <input name="cookbookName" class="easyui-textbox">
        </div>
        <div class="fitem searchItem fr">
            <a class="easyui-linkbutton" iconCls="icon-search" onclick="sy_searchFun()">搜索</a>
            <a class="easyui-linkbutton" iconCls="icon-reload" onclick="sy_resetFun()">重置</a>
        </div>
    </form>
</div>
<div data-options="region:'center',border:false">
    <table id="grid" class="easyui-datagrid" fit="true"
           data-options="url: '<%=contextPath%>/cookbook/list',method: 'post',pagination: true,rownumbers:true,idField: 'id', fitColumns:true,singleSelect:true,striped:true,sortName:'createTime',sortOrder:'desc',toolbar: '#toolbar'">
        <thead>
        <tr><%--<div>
            <th field="img"  data-options="formatter:function(v){return '<img style=\'width: 60px;\' src=/cookbook/getFirstImg?imgNames='+v+'/>'}"><strong>图片</strong></th>
            </div>--%>

            <th data-options="field:'cookbookName'" width="100" sortable="true">菜谱名称</th>
            <th data-options="field:'comments'" width="100" sortable="true">点评</th>
            <th data-options="field:'createName'" width="100" sortable="true">发布人</th>
            <th data-options="field:'createTime'" width="100" sortable="true">发布时间</th>
            <th data-options="field:'praiseCount'" width="100" sortable="true">点赞数</th>
            <th data-options="field:'readCount'" width="100" sortable="true">阅读数</th>
            <th data-options="field:'commentCount'" width="100" sortable="true">评论数</th>
        </tr>
        </thead>
    </table>
</div>
<!-- 按钮-->
<div id="toolbar" style="display: none;">
    <t:button action="cookbook_add" iconCls="icon-add" buttonName="新增" onclick="sy_addFun('/cookbook/toSaveAndUpdate/','添加菜谱信息',600,700)"/>
    <t:button action="cookbook_edit" iconCls="icon-edit" buttonName="编辑" onclick="sy_editFun('/cookbook/toSaveAndUpdate/','修改菜谱信息',600,700)"/>
    <t:button action="cookbook_remove" iconCls="icon-remove" buttonName="删除" onclick="sy_removeGridFun_tip('/cookbook/delete')"/>
    <t:button action="ingredients_list" iconCls="icon-add" buttonName="添加食材" onclick="related_list('/ingredients/toDatagrid','食材信息',800,600)"/>
    <t:button action="planlibrary_list" iconCls="icon-add" buttonName="烹饪步骤" onclick="related_list('/cookingSteps/toDatagrid','烹饪信息',800,600)"/>
    <t:button action="cookbook_details" iconCls="icon-add" buttonName="预览" onclick="preview('/cookbook/preview','cookbook预览')"/>
</div>
<script>
    var $grid;
    var related_list = function(url,title,width,height){
            debugger;
        $grid = $("#grid");

        var rows = $grid.datagrid('getSelections');
        if (rows.length == 0) {
            parent.$.messager.alert('提示', "请选择一条数据", 'error');
            return;
        } else if (rows.length > 1) {
            parent.$.messager.alert('提示', "只能选择一条数据", 'error');
            return;
        } else {
            url = url + "/" + rows[0].id;
        }
        var dialog = parent.sy.modalDialog({
            title: title,
            url: url,
            width: width,
            height: height,
            buttons:  {
                text: '取消',
                iconCls: "icon-cancel",
                handler: function () {
                    dialog.dialog('destroy');
                }
            }
        });

    }

</script>
</body>

</html>



